package com.wanxi.dao.impl;

import com.wanxi.dao.CompanyDao;
import com.wanxi.dto.CompanyDto;
import com.wanxi.model.CompanyModel;
import com.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;

public class CompanyDaoImpl implements CompanyDao {
    @Override
    public CompanyDto getCompanyDto(CompanyModel companyModel) {
        String sql = "select * from company where is_show=1";
        ResultSet query = JDBC.query(sql);
        try {
            while (query.next()) {
                return CompanyDto.builder()
                        .logo(query.getString("logo"))
                        .phone(query.getString("phone"))
                        .net(query.getString("net"))
                        .email(query.getString("email"))
                        .linePhone(query.getString("line_phone"))
                        .address(query.getString("address"))
                        .version(query.getString("version"))
                        .build();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
